# include <stdio.h>
int main()
{
	int a = 0;
	int b = 0;
	int max = 0;
	scanf_s("%d %d", &a, &b);
	max = a > b ? b: a;
	while (1)
	{
		if (0 == a % max && 0 == b % max)
		{
			break;
		}
		max--;
	}
	printf("%d", max);
	return 0;
}